home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic new SourceCode and Projects / MP3 Player / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-12-21  |  13.8 KB  |  461 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "{22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0"; "MSDXM.OCX"
  4. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  5. Object = "{B0E4B491-7E7B-11D0-8E50-444553540000}#4.0#0"; "ICONTRAY.OCX"
  6. Begin VB.Form frmMain 
  7.    Caption         =   "MP3 Player"
  8.    ClientHeight    =   4605
  9.    ClientLeft      =   165
  10.    ClientTop       =   735
  11.    ClientWidth     =   3855
  12.    Icon            =   "frmMain.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   307
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   257
  17.    StartUpPosition =   3  'Windows Default
  18.    Begin IconTrayOCX.IconTray IconTray1 
  19.       Left            =   1455
  20.       Top             =   4215
  21.       _ExtentX        =   688
  22.       _ExtentY        =   741
  23.    End
  24.    Begin VB.OptionButton Option1 
  25.       Caption         =   "&None"
  26.       Height          =   195
  27.       Left            =   3180
  28.       TabIndex        =   14
  29.       Top             =   4065
  30.       Value           =   -1  'True
  31.       Width           =   735
  32.    End
  33.    Begin VB.CommandButton cmdCd 
  34.       Caption         =   "Open CD ROM"
  35.       BeginProperty Font 
  36.          Name            =   "Arial"
  37.          Size            =   8.25
  38.          Charset         =   0
  39.          Weight          =   400
  40.          Underline       =   0   'False
  41.          Italic          =   0   'False
  42.          Strikethrough   =   0   'False
  43.       EndProperty
  44.       Height          =   735
  45.       Left            =   2880
  46.       TabIndex        =   12
  47.       Top             =   2940
  48.       Width           =   735
  49.    End
  50.    Begin VB.CommandButton cmdSys 
  51.       Caption         =   "Show in Sys Tray"
  52.       Height          =   285
  53.       Left            =   30
  54.       TabIndex        =   10
  55.       Top             =   4020
  56.       Width           =   1455
  57.    End
  58.    Begin VB.OptionButton optRnd 
  59.       Caption         =   "Random"
  60.       Height          =   255
  61.       Left            =   2265
  62.       TabIndex        =   9
  63.       Top             =   4035
  64.       Width           =   975
  65.    End
  66.    Begin VB.OptionButton chkOrd 
  67.       Caption         =   "Order"
  68.       Height          =   255
  69.       Left            =   1590
  70.       TabIndex        =   8
  71.       Top             =   4035
  72.       Width           =   975
  73.    End
  74.    Begin VB.CommandButton cmdRes 
  75.       Caption         =   "Resume"
  76.       Enabled         =   0   'False
  77.       Height          =   375
  78.       Left            =   2880
  79.       TabIndex        =   7
  80.       Top             =   2460
  81.       Width           =   735
  82.    End
  83.    Begin VB.CommandButton cmdPause 
  84.       Caption         =   "Pause"
  85.       Height          =   375
  86.       Left            =   2880
  87.       TabIndex        =   6
  88.       Top             =   1980
  89.       Width           =   735
  90.    End
  91.    Begin MSComctlLib.Slider Slider1 
  92.       Height          =   255
  93.       Left            =   45
  94.       TabIndex        =   5
  95.       Top             =   660
  96.       Width           =   3645
  97.       _ExtentX        =   6429
  98.       _ExtentY        =   450
  99.       _Version        =   393216
  100.    End
  101.    Begin VB.Timer Timer1 
  102.       Left            =   360
  103.       Top             =   4260
  104.    End
  105.    Begin VB.CommandButton cmdStop 
  106.       Caption         =   "Stop"
  107.       Height          =   375
  108.       Left            =   2880
  109.       TabIndex        =   4
  110.       Top             =   1500
  111.       Width           =   735
  112.    End
  113.    Begin VB.CommandButton cmdPlay 
  114.       Caption         =   "Play"
  115.       Enabled         =   0   'False
  116.       Height          =   375
  117.       Left            =   2880
  118.       TabIndex        =   3
  119.       Top             =   1020
  120.       Width           =   735
  121.    End
  122.    Begin VB.FileListBox File1 
  123.       Height          =   2625
  124.       Left            =   75
  125.       Pattern         =   "*.mp3"
  126.       TabIndex        =   2
  127.       Top             =   1005
  128.       Width           =   2655
  129.    End
  130.    Begin MSComDlg.CommonDialog Dialog 
  131.       Left            =   1920
  132.       Top             =   4080
  133.       _ExtentX        =   847
  134.       _ExtentY        =   847
  135.       _Version        =   393216
  136.    End
  137.    Begin VB.Label Label1 
  138.       BorderStyle     =   1  'Fixed Single
  139.       Caption         =   "Song"
  140.       Height          =   255
  141.       Left            =   120
  142.       TabIndex        =   1
  143.       Top             =   120
  144.       Width           =   3495
  145.    End
  146.    Begin VB.Label lblPath 
  147.       AutoSize        =   -1  'True
  148.       BorderStyle     =   1  'Fixed Single
  149.       Height          =   255
  150.       Left            =   120
  151.       TabIndex        =   11
  152.       Top             =   3735
  153.       Width           =   105
  154.    End
  155.    Begin MediaPlayerCtl.MediaPlayer MP3Player 
  156.       Height          =   375
  157.       Left            =   945
  158.       TabIndex        =   0
  159.       Top             =   4200
  160.       Visible         =   0   'False
  161.       Width           =   495
  162.       AudioStream     =   -1
  163.       AutoSize        =   0   'False
  164.       AutoStart       =   -1  'True
  165.       AnimationAtStart=   -1  'True
  166.       AllowScan       =   -1  'True
  167.       AllowChangeDisplaySize=   -1  'True
  168.       AutoRewind      =   0   'False
  169.       Balance         =   0
  170.       BaseURL         =   ""
  171.       BufferingTime   =   3
  172.       CaptioningID    =   ""
  173.       ClickToPlay     =   -1  'True
  174.       CursorType      =   0
  175.       CurrentPosition =   -1
  176.       CurrentMarker   =   0
  177.       DefaultFrame    =   ""
  178.       DisplayBackColor=   0
  179.       DisplayForeColor=   16777215
  180.       DisplayMode     =   0
  181.       DisplaySize     =   4
  182.       Enabled         =   -1  'True
  183.       EnableContextMenu=   -1  'True
  184.       EnablePositionControls=   -1  'True
  185.       EnableFullScreenControls=   0   'False
  186.       EnableTracker   =   -1  'True
  187.       Filename        =   ""
  188.       InvokeURLs      =   0   'False
  189.       Language        =   -1
  190.       Mute            =   0   'False
  191.       PlayCount       =   0
  192.       PreviewMode     =   0   'False
  193.       Rate            =   1
  194.       SAMILang        =   ""
  195.       SAMIStyle       =   ""
  196.       SAMIFileName    =   ""
  197.       SelectionStart  =   -1
  198.       SelectionEnd    =   -1
  199.       SendOpenStateChangeEvents=   -1  'True
  200.       SendWarningEvents=   -1  'True
  201.       SendErrorEvents =   -1  'True
  202.       SendKeyboardEvents=   0   'False
  203.       SendMouseClickEvents=   0   'False
  204.       SendMouseMoveEvents=   0   'False
  205.       SendPlayStateChangeEvents=   -1  'True
  206.       ShowCaptioning  =   0   'False
  207.       ShowControls    =   -1  'True
  208.       ShowAudioControls=   -1  'True
  209.       ShowDisplay     =   0   'False
  210.       ShowGotoBar     =   0   'False
  211.       ShowPositionControls=   -1  'True
  212.       ShowStatusBar   =   0   'False
  213.       ShowTracker     =   -1  'True
  214.       TransparentAtStart=   0   'False
  215.       VideoBorderWidth=   0
  216.       VideoBorderColor=   0
  217.       VideoBorder3D   =   0   'False
  218.       Volume          =   0
  219.       WindowlessVideo =   0   'False
  220.    End
  221.    Begin VB.Label lblTotal 
  222.       AutoSize        =   -1  'True
  223.       BorderStyle     =   1  'Fixed Single
  224.       Caption         =   "Total number of mp3's:"
  225.       Height          =   255
  226.       Left            =   120
  227.       TabIndex        =   13
  228.       Top             =   360
  229.       Width           =   1665
  230.    End
  231.    Begin VB.Menu mnufolder 
  232.       Caption         =   "&Folder of mp3's"
  233.    End
  234.    Begin VB.Menu mnuAbout 
  235.       Caption         =   "&About"
  236.    End
  237.    Begin VB.Menu mnuOptions 
  238.       Caption         =   "&Options"
  239.       Visible         =   0   'False
  240.       Begin VB.Menu mnuShow 
  241.          Caption         =   "&Show Mp3 Player"
  242.       End
  243.       Begin VB.Menu dash 
  244.          Caption         =   "-"
  245.       End
  246.       Begin VB.Menu mnuEnd 
  247.          Caption         =   "&End Mp3PLayer"
  248.       End
  249.    End
  250. Attribute VB_Name = "frmMain"
  251. Attribute VB_GlobalNameSpace = False
  252. Attribute VB_Creatable = False
  253. Attribute VB_PredeclaredId = True
  254. Attribute VB_Exposed = False
  255. Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  256. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  257. Private Sub chkOrd_Click()
  258. On Error Resume Next
  259. File1.ListIndex = 0
  260. If chkOrd.Value = True Then
  261.     cmdPlay.Enabled = True
  262.     optRnd.Value = False
  263.     'File1.ListIndex = 1
  264.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  265.     MP3Player.Play
  266.     Slider1.Max = MP3Player.Duration
  267.     Timer1.Interval = 1
  268.     Label1.Caption = MP3Player.FileName
  269. End If
  270. End Sub
  271. Private Sub cmdCd_Click()
  272. If cmdCd.Caption = "Open CD ROM" Then
  273.     cmdCd.Caption = "Close CD ROM"
  274.     mciSendString "Set CDAudio Door Open Wait", _
  275.     0&, 0&, 0&
  276. ElseIf cmdCd.Caption = "Close CD ROM" Then
  277.     cmdCd.Caption = "Open CD ROM"
  278.     mciSendString "Set CDAudio Door Closed Wait", _
  279.     0&, 0&, 0&
  280. End If
  281. End Sub
  282. Private Sub cmdPause_Click()
  283. On Error Resume Next
  284. MP3Player.Pause
  285. cmdPause.Enabled = False
  286. cmdRes.Enabled = True
  287. End Sub
  288. Private Sub cmdPlay_Click()
  289. On Error Resume Next
  290. Dim MyValue
  291. Dim Total As Integer
  292. If optRnd.Value = True Then
  293.     MyValue = Int((File1.ListCount * Rnd))
  294.     File1.ListIndex = MyValue
  295.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  296.     MP3Player.Play
  297.     Slider1.Max = MP3Player.Duration
  298.     Timer1.Interval = 1
  299.     Label1.Caption = MP3Player.FileName
  300.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  301.     MP3Player.Play
  302.     Slider1.Max = MP3Player.Duration
  303.     Timer1.Interval = 1
  304.     Label1.Caption = MP3Player.FileName
  305. End If
  306. If chkOrd.Value = True Then
  307.     Total = File1.ListCount
  308.     'File1.ListIndex = File1.ListIndex + 1
  309.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  310.     MP3Player.Play
  311.     Slider1.Max = MP3Player.Duration
  312.     Timer1.Interval = 1
  313.     Label1.Caption = MP3Player.FileName
  314. End If
  315. End Sub
  316. Private Sub cmdRes_Click()
  317. On Error Resume Next
  318. MP3Player.Play
  319. MP3Player.CurrentPosition = Slider1.Value
  320. cmdRes.Enabled = False
  321. cmdPause.Enabled = True
  322. End Sub
  323. Private Sub cmdStop_Click()
  324. Slider1.Value = 0
  325. Timer1.Interval = 0
  326. MP3Player.CurrentPosition = 0
  327. MP3Player.Stop
  328. Label1.Caption = File1.Path & "\" & File1.FileName
  329. cmdRes.Enabled = False
  330. End Sub
  331. Private Sub cmdSys_Click()
  332. IconTray1.Icon = frmMain.Icon
  333. IconTray1.ToolTip = "MP3 Player"
  334. IconTray1.Add
  335. cmdSys.Enabled = False
  336. Me.Visible = False
  337. End Sub
  338. Private Sub Command1_Click()
  339. End Sub
  340. Private Sub File1_Click()
  341. cmdPlay.Enabled = True
  342. Label1.Caption = File1.Path & "\" & File1.FileName
  343. End Sub
  344. Private Sub Form_Load()
  345. On Error Resume Next
  346. 'chkOrd.Value = True
  347. ChDir App.Path
  348. Open App.Path & "\" & "default.Dat" For Input Access Read As #1
  349. Input #1, Ddefault
  350. File1.Path = Ddefault
  351. lblPath.Caption = Ddefault
  352. MP3Player.BaseURL = Ddefault
  353. lblTotal.Caption = "Total number of mp3's: " & File1.ListCount
  354. Close #1
  355. End Sub
  356. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  357. IconTray1.Remove
  358. Open App.Path & "\" & "default.Dat" For Input Access Read As #1
  359. Close #1
  360. End Sub
  361. Private Sub HScroll1_Scroll()
  362. MP3Player.CurrentPosition = HScroll1.Value
  363. End Sub
  364. Private Sub IconTray1_LeftDblClick()
  365. frmMain.Show
  366. IconTray1.Remove
  367. cmdSys.Enabled = True
  368. End Sub
  369. Private Sub IconTray1_RightClick()
  370. PopupMenu mnuOptions
  371. End Sub
  372. Private Sub mnuAbout_Click()
  373. frmAbout.Show
  374. End Sub
  375. Private Sub mnuEnd_Click()
  376. IconTray1.Remove
  377. End Sub
  378. Private Sub mnufolder_Click()
  379. Me.Visible = False
  380. frmfolder.Show
  381. End Sub
  382. Private Sub mnuShow_Click()
  383. frmMain.Show
  384. IconTray1.Remove
  385. cmdSys.Enabled = True
  386. End Sub
  387. Private Sub MP3Player_EndOfStream(ByVal Result As Long)
  388. 'File1.ListIndex = 1
  389. Dim MyValue
  390. If optRnd.Value = True And MP3Player.CurrentPosition = MP3Player.Duration Then
  391.     MyValue = Int((File1.ListCount * Rnd))
  392.     File1.ListIndex = MyValue
  393.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  394.     MP3Player.Play
  395.     Slider1.Max = MP3Player.Duration
  396.     Timer1.Interval = 1
  397.     Label1.Caption = MP3Player.FileName
  398.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  399.     MP3Player.Play
  400.     Slider1.Max = MP3Player.Duration
  401.     Timer1.Interval = 1
  402.     Label1.Caption = MP3Player.FileName
  403.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  404.     MP3Player.Play
  405.     Slider1.Max = MP3Player.Duration
  406.     Timer1.Interval = 1
  407.     Label1.Caption = MP3Player.FileName
  408. End If
  409. If chkOrd.Value = True Then
  410.     Total = File1.ListCount
  411.     File1.ListIndex = File1.ListIndex + 1
  412.     MP3Player.FileName = File1.Path & "\" & File1.FileName
  413.     MP3Player.Play
  414.     Slider1.Max = MP3Player.Duration
  415.     Timer1.Interval = 1
  416.     Label1.Caption = MP3Player.FileName
  417. End If
  418. End Sub
  419. Private Sub MP3Player_Error()
  420. 'MsgBox "An error has occured to mp3Player"
  421. End Sub
  422. Private Sub Option1_Click()
  423. If chkOrd.Value = 1 Then
  424. cmdPlay.Enabled = True
  425. File1.ListIndex = 0
  426. optRnd.Value = 0
  427. MP3Player.FileName = File1.Path & "\" & File1.FileName
  428. MP3Player.Play
  429. Slider1.Max = MP3Player.Duration
  430. Timer1.Interval = 1
  431. Label1.Caption = MP3Player.FileName
  432. End If
  433. End Sub
  434. Private Sub optRnd_Click()
  435. On Error Resume Next
  436. cmdPlay.Enabled = True
  437. chkOrd.Value = False
  438. End Sub
  439. Private Sub Slider1_Scroll()
  440. MP3Player.CurrentPosition = Slider1.Value
  441. End Sub
  442. Private Sub SystemTray1_IconAdded()
  443. SystemTray1.Action = sys_modify
  444. End Sub
  445. Private Sub SystemTray1_IconDeleted()
  446. SystemTray1.Action = sys_modify
  447. End Sub
  448. Private Sub SystemTray1_MouseDblClk(ByVal Button As Integer)
  449. SystemTray1.Action = sys_delete
  450. SystemTray1.Action = sys_modify
  451. frmMain.Visible = True
  452. cmdSys.Enabled = True
  453. End Sub
  454. Private Sub SystemTray1_MouseMove()
  455. SystemTray1.SysTrayText = "mp3 Player"
  456. SystemTray1.Action = sys_modify
  457. End Sub
  458. Private Sub Timer1_Timer()
  459. Slider1.Value = MP3Player.CurrentPosition
  460. End Sub
  461.